<?php
namespace App\Models;
use App\Constant\Constant;
use Carbon\Carbon;
use App\Models\BaseModel;
use App\Helpers\MoneyHelper;
use App\Format\BaseFormat;

/**
 * App\Models\Label
 *
 * @property int $id
 * @property string $name 名称
 * @property string $icon 图标
 * @property int $type 类型：1酒店设施
 * @property int $is_delete 是否删除：1是 0否
 * @property \Illuminate\Support\Carbon $created_at
 * @property \Illuminate\Support\Carbon $updated_at
 * @property-read mixed $faddress
 * @method static \Illuminate\Database\Eloquent\Builder|Label apiBaseQuery($whereParams = [])
 * @method static \Illuminate\Database\Eloquent\Builder|Label bgBaseQuery($whereParams = [])
 * @method static \Illuminate\Database\Eloquent\Builder|Label newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Label newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel paramsQuery($fields, $params = [])
 * @method static \Illuminate\Database\Eloquent\Builder|Label query()
 * @method static \Illuminate\Database\Eloquent\Builder|Label whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Label whereIcon($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Label whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|BaseModel whereIds($ids = [])
 * @method static \Illuminate\Database\Eloquent\Builder|Label whereIsDelete($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Label whereName($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Label whereType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Label whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|Label hotelFacilityQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|Label hotelPhotoTypeQuery()
 * @mixin \Eloquent
 */
class Label extends BaseModel
{
    /**
     * Define table name
     *
     * @var string
     */
    protected $table = 'labels';

    /**
     * Define a primary key
     *
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * A property that cannot be batched.
     *
     * @var array
     */
    protected $guarded = ['id'];
    protected $hidden = ['updated_at'];
    /*********************************************属性格式化***************************************************************/

    /*********************************************设置属性***************************************************************/

    /*********************************************模型操作***************************************************************/
    public function scopeBgBaseQuery($query, $whereParams = []) {
        $query->paramsQuery(['name', 'type'], $whereParams);
    }
    public function scopeApiBaseQuery($query, $whereParams = []) {
    }
    // 查询酒店设施
    public function scopeHotelFacilityQuery($query)
    {
        return $query->where("{$this->table}.type", Constant::LabelType_HotelFacility);
    }

    // 查询酒店相册分类
    public function scopeHotelPhotoTypeQuery($query)
    {
        return $query->where("{$this->table}.type", Constant::LabelType_HotelPhoto);
    }

    public static function getForms($fields = [], $type = 'search', $width = '300px') {
        $forms = [
            'name' => ['title' => '名称', 'type' => 'text'],
            'icon' => ['title' => '图标', 'type' => 'image'],
            'type' => ['type' => 'hidden']
        ];
        return self::handleForms($forms, $fields, $type, $width);
    }
    /*********************************************模型关联***************************************************************/

}
